import "@/style/entry.scss"
import Header from "@/components/header";
import { Outlet, useLocation } from "react-router-dom";
import { useSelector } from "react-redux";
import { ConfigProvider, theme } from 'antd'
import { PrivateRoute } from "@/router";

const { darkAlgorithm, defaultAlgorithm } = theme;
const Entry = () => {
    const location = useLocation();
    const globalTheme = useSelector((state: any) => state.theme);
    let antdTheme: any = { algorithm: globalTheme.dark ? darkAlgorithm : defaultAlgorithm };
    if (globalTheme.colorPrimary) {
        antdTheme.token = { colorPrimary: globalTheme.colorPrimary };
    }
    return (
        <PrivateRoute>
            <ConfigProvider theme={antdTheme}>
                <div className="entryBox">
                    <Header title={location.pathname} />
                    <div className="entryContent">
                        <Outlet />
                    </div>
                </div>
            </ConfigProvider>
        </PrivateRoute>


    );
};

export default Entry;